<?php

class ToolDialog extends WBToolDialog { 


	
	public function __construct($options = array()) { 
		parent::__construct($options);
	}
	
	public function __destruct() { 
		parent::__destruct();
		
		unset($this->_items);
	}	
	
	public function initCreate() { 
		parent::initCreate();
		
		$pos = $this->getOption('parent')->getPosition();
		
		$this->setOption('width', 88);
		$this->setOption('height', 300);
		
		$this->setOption('x', max(0, $pos['x'] - $this->getOption('width')));
		$this->setOption('y', max(0, $pos['y']));
	}
	
	public function initComponent() { 
		parent::initComponent();
		
		$this->createControl();
	}
	
	public function createControl() { 
		
		foreach ($this->_items as $i => $item) { 
			$image = RESOURCE_HOME."ctrl_${item['name']}3.bmp";
			$com = $this->add(array(
				'wbtype' => 'ImageButton',
				'x' => 4 + 25 * ($i % 3),
				'y' => 4 + 25 * (int)($i / 3),
				'width' => 24,
				'height' => 24,
				'caption' => $item['name'],
				'image' => $image,
				'event' => array(
					'click' => array($this, 'createSubControl')
				)
			));
		}
		
		//$this->doLayout();
	}
	
	public function createSubControl($eo) { 
		$text = $eo->object()->text;
		
		$this->getOption('parent')->createControlInProject($text);
	}
	
	public function onClose($eo = null) {
		
	}
}

?>